<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta content="telephone=no" name="format-detection" />
  <meta itemprop="name" content="谁说人算不如天算？快来和我一起预测押题疯狂提分！" />
  <meta itemprop="image" content="/img/ygshare.jp" />
  <meta name="description" itemprop="description" content="《高考命题预测与题——2018临考押题卷》首发预售，火热上线！" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
  <link rel="stylesheet" href="/css/reset.css">
  <link rel="stylesheet" href="/css/normalize.css">
  <link rel="stylesheet" href="/css/yg/yg-signup.css">
  <title>2018临考押题卷</title>
  <% include ../component/_common_tongji.html %>
    <style>
      [v-cloak] {
        display: none;
      }

      #show {
        display: none;
      }
    </style>
    <script>
      var scale = 1 / devicePixelRatio;
      document.querySelector('meta[name="viewport"]').setAttribute('content', 'width=device-width, initial-scale=' + scale + ', maximum-scale=' + scale + ', minimum-scale=' + scale + ', user-scalable=no');
      document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
    </script>
    <script>
      window.onload = function () {
        var compa = document.querySelector('#show');
        if (compa) {
          compa.style.display = 'block';
        }
      }
      function browserRedirect() {
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
        if ((bIsIpad || bIsIphoneOs)) {
          document.getElementsByTagName('html')[0].style.fontFamily = 'PingFangSC-Regular';
        }
      }
      browserRedirect();
    </script>
</head>

<body>
  <div id="app" style="height:100%">
    <div v-if="false" style="font-size:0.3rem;" id="show">您的浏览器版本太低请升级浏览器或者使用Chrome浏览器</div>
    <div v-cloak class="cloak">
      <div class="query" v-if="!signUpInfo.token">
        <p>登录</p>
        <% include ../signup/login.html %>
      </div>
      <div class="pay" v-if="signUpInfo.token && signUpInfo.token != ''">
        <% include ../signup/top_infomation.html %>
          <% include ../signup/tg/userInfo.html %>
            <% include ../signup/tg/chooseType.html %>
              <% include ../signup/tg/chooseArt.html %>
                <% include ../signup/footer_pay_type.html %>
                  <% include ../signup/tg/footer.html %>
                    <% include ../signup/tg/address.html %>
      </div>
    </div>
  </div>
  <script src="https://sfile.tl100.com/js/libs/vue.min.js"></script>
  <script src="https://sfile.tl100.com/js/libs/axios.min.js"></script>
  <script src="/js/api.js"></script>
  <script src="/js/wx.js"></script>
  <script src="/js/login/login.js"></script>
  <script src="/js/pay/pay.js"></script>
  <script src="/js/getuserinfo.js"></script>
  <% if(pt == 'qq'){%>
    <script src="https://sfile.tl100.com/js/libs/qqapi.js"></script>
    <%}%>
      <script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
      <script>  
        var app = new Vue({
          el: '#app',
          data: {
            smsText: '发送验证码',
            cityListXZP: [],
            cityListXZ: [],
            cityListXZS: [],
            sign_up_price: '',
            original_price: '',
            cityss: '',
            title: '高考命题预测与题——2018临考押题卷',
            titleImg: '/img/juan.jpg',
            yhmoney: '',
            payMode: {
              pay: '购买优惠：',
              yhmoney: '新书购买减40元',
            },
            loginInfo: {
              phone: '',
              sms: ''
            },
            signUpInfo: {
              realname: '',
              city: '选择区域',
              provice_code: '选择省市',
              city_code: '',
              pay_type: 1,
              exam_id: 3,
              options: {
                name: '全国I卷',
                subject: '理科'
              },
              invitation_code: '',
              return_url: '',
              receiving_address: '',
              receiving_phone: '',
              origin: '',
              code: '',
              token: '',
              from: 'wap'
            },
            addAddressMode: false,
            smsSending: false,
            enter: false,
            submiting: false,
            typeMode: false,
            typeMode2: false,
            typeArt: false,
            pay: true
          },
          mounted: function () {
            this.signUpInfo.token = localStorage.getItem('token');
            if (this.signUpInfo.token && this.signUpInfo.token != '') {
              this.getUserInfo();
            }
            this.handlerGetBookInfo();
            // 城市
            var _this = this;
            api.post('/api/base_info/getXZProvinceList').then(function (res) {
              _this.cityListXZP = res.data.msg;
            });
            <% if (code) {%>
              this.signUpInfo.code = "<%= code %>";
            <%}%>
            <% if (origin) {%>
              this.signUpInfo.origin = "<%= origin %>";
            <%}%> 
            <% if (invitation_code) {%>
              this.signUpInfo.invitation_code = "<%= invitation_code %>";
            <%}%>
            <% if (pt) {%>
              this.signUpInfo.from = "<%= pt %>";
            <%}%>
            if (this.signUpInfo.from == 'wechat') {
              this.signUpInfo.pay_type = 1;
            }
            if (this.signUpInfo.from == 'wap') {
              this.signUpInfo.pay_type = 2;
            }
            if (this.signUpInfo.from == 'qq') {
              this.signUpInfo.pay_type = 3;
            }
            wxObj({
              shareUrl: 'https://m.tl100.com/yg?pt=' + this.signUpInfo.from,
              title: '谁说人算不如天算？快来和我一起预测押题疯狂提分！',
              desc: '《高考命题预测与题——2018临考押题卷》首发预售，火热上线！',
              link: '&',
              imgUrl: 'img/ygshare.jpg'
            });
            this.signUpInfo.return_url = "https://m.tl100.com/yg/signup";
          },
          methods: {
            handlecityList() {
              var vm = this;
              api.post('/api/base_info/getXZCityList', {
                province_code: this.cityListXZP[this.signUpInfo.provice_code].code
              }).then(function (res) {
                vm.cityListXZ = res.data.msg;
              });
            },
            handlecityListXZS () {
              var vm = this;
              api.post('/api/base_info/getXZAreaList', {
                province_code: this.cityListXZP[this.signUpInfo.provice_code].code,
                city_code: this.cityListXZ[this.signUpInfo.city_code].code
              }).then(function (res) {
                vm.cityListXZS = res.data.msg;
              });
            },
            changeVersion(name) {
              this.signUpInfo.options.name = name;
              this.typeMode = false;
              this.pay = true;
            },
            changeSubject(subject) {
              this.signUpInfo.options.subject = subject;
              this.typeMode2 = false;
              this.pay = true;
            },
            handleChooseType() {
              this.typeMode = true;
              this.pay = false;
            },
            handleChooseArt() {
              this.typeMode2 = true;
              this.pay = false;
            },
            handleCancel() {
              this.typeMode = false;
              this.typeMode2 = false;
              this.pay = true;
            },
            handlerGetBookInfo() {
              var vm = this;
              api.post('/api/pre_buy_book/getBookInfo')
                .then(function (res) {
                  if (res.data.res_code == 1) {
                    vm.sign_up_price = res.data.msg.sign_up_price;
                    vm.original_price = res.data.msg.original_price;
                    vm.yhmoney = res.data.msg.original_price - res.data.msg.sign_up_price;
                  } else {
                    setLog('/api/pre_buy_book/getBookInfo:fail', JSON.stringify(res.data));
                  }
                }).catch(function (error) {
                  setLog('/api/pre_buy_book/getBookInfo:catch', JSON.stringify(error));
                });
            },
            handleAdd() {
              this.addAddressMode = true;
            },
            handleAddress() {
              this.addAddressMode = false;
            },
            handleKeep() {
              this.addAddressMode = false;
              var vm = this;
              vm.cityss = this.cityListXZP[this.signUpInfo.provice_code].name+this.cityListXZ[this.signUpInfo.city_code].name+this.cityListXZS[this.signUpInfo.city].name;
              var a = vm.cityss+this.signUpInfo.receiving_address;
              api.post('/api/pre_buy_book/setReceivingInfo', {
                receiving_name: this.signUpInfo.realname,
                receiving_phone: this.signUpInfo.receiving_phone,
                receiving_address: a,
                receiving_city: this.cityListXZS[this.signUpInfo.city].code,
                token: this.signUpInfo.token
              }).then(function (res) {
                if (res.data.res_code < 0) {
                  setLog('/api/pre_buy_book/setReceivingInfo:fail', JSON.stringify(res.data));
                }
              }).catch(function (error) {
                setLog('/api/pre_buy_book/setReceivingInfo:catch', JSON.stringify(error));
              });
            },
            getUserInfo: function () {
              var vm = this;
              var token = localStorage.getItem('token');
              getUserInfo(this, token, '/api/user/getUserInfo', function (res_date) {
                var res = res_date;
                vm.signUpInfo.realname = res.data.msg.receiving_name;
                vm.signUpInfo.receiving_phone = res.data.msg.receiving_phone;
                vm.signUpInfo.receiving_address = res.data.msg.receiving_address;
                // vm.signUpInfo.city = res.data.msg.receiving_city;
                var sign_info = res.data.msg.all_sign_up_info;
                if (sign_info && sign_info.length > 0) {
                  for (var i = 0; i < sign_info.length; i++) {
                    if (sign_info[i].exam_id == 3 && sign_info[i].state > 0) {
                      location.replace("/yg/success?invitation_code=" + res.data.msg.invitation_code);
                      break;
                    }
                  }
                }
              })
            },
            handleSend: function () {
              send(this);
            },
            handleEnter: function () {
              var vm = this;
              enter(this, function (res) {
                var res_data = res.data.msg.all_sign_up_info;
                for (var i = 0; i < res_data.length; i++) {
                  if (res_data[i].exam_id == 3 && res_data[i].state > 0) {
                    location.replace("/yg/success?invitation_code=" + res_data[i].invitation_code);
                  }
                }
                vm.signUpInfo.realname = res.data.msg.user_info.realname;
                vm.signUpInfo.receiving_phone = res.data.msg.user_info.receiving_phone;
                vm.signUpInfo.receiving_address = res.data.msg.user_info.receiving_address;
                vm.signUpInfo.receiving_city = res.data.msg.user_info.receiving_city;
                vm.signUpInfo.token = res.data.msg.token;
                vm.getUserInfo();
              });
            },
            handleSubmit: function () {
              if (this.submiting) {
                return;
              }
              if (this.signUpInfo.realname == "") {
                alert('姓名不能为空');
                return;
              }
              if (this.signUpInfo.realname.length > 6) {
                alert('最多输入6个汉字或英文字母！');
                return;
              }
              if (this.signUpInfo.receiving_address == '') {
                alert('收货地址不能为空');
                return;
              }
              if (this.signUpInfo.receiving_phone == '') {
                alert('电话号不能为空');
                return;
              }
              if (!(/^[1][3,4,5,7,8][0-9]{9}$/.test(this.signUpInfo.receiving_phone))) {
                alert("请输入正确的手机号码！");
                return false;
              }
              var that = this;
              this.submiting = true;
              submit(this, '/api/pre_buy_book/preBuy', '/api/pre_buy_book/getOrder');
            },
            handleToggle: function () {
              localStorage.removeItem('token');
              location.replace('/yg/signup');
            }
          }
        })

      </script>
</body>

</html>